package com.heima.lianxi.maohao;

import java.util.Arrays;

public class maohao {
    public static void main(String[] args) {
        int[] arr = {1, 5, 8, 7, 6, 2, 4};

        for (int j = 0; j < arr.length -1; j++) {
            for (int i = 0; i < arr.length - j - 1; i++) {
                if (arr[i] > arr[i+1]) {
                    int num = arr[i];
                    arr[i] = arr[i+1];
                    arr[i+1] = num;
                }
            }
        }
        System.out.println(Arrays.toString(arr));


    }
}
